package com.zhujiaji.service;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @author 朱佳吉
 * @date 2024/3/16 21:48
 */
@Component
public class RedisService {

    @Resource
    RedisTemplate redisTemplate;

    public void setString(String key, String value, long expireTime, TimeUnit timeUnit) {
        redisTemplate.opsForValue().set(key, value, expireTime, timeUnit);
    }

    public String getString(String key) {
        return (String) redisTemplate.opsForValue().get(key);
    }
}
